package com.xjk.springcloudnacos.controller;

import com.alibaba.nacos.api.config.annotation.NacosValue;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author: XJK
 */
@Controller
@RequestMapping("/config")
public class MyController {

    // 通过 Nacos 的 @NacosValue 注解设置属性值。
    @NacosValue(value = "${useLocalCache:false}", autoRefreshed = true)
    private boolean useLocalCache;

    @RequestMapping(value = "/get",method = RequestMethod.GET)
    @ResponseBody
    public boolean getValue(){
        return useLocalCache;
    }

}
